package com.yb.bussiness.goods;

import com.yb.base.dao.BaseDao;
import com.yb.base.dao.IBaseDao;
import com.yb.domain.goods.TrMessageCommend;

public class TrMessageCommendServiceImpl implements TrMessageCommendService {
	private IBaseDao<TrMessageCommend, Long> dao;

	public TrMessageCommendServiceImpl() {
		dao = new BaseDao<TrMessageCommend, Long>(TrMessageCommend.class);
	}

	public boolean checkMessage(Long userId, Long messageId) {
		String sql = "select count(*) from t_r_messagecommend where userId = ? and messageId = ?";
		Object[] countAry = dao.findObjectArryList(sql,
				new Object[] { userId, messageId }).get(0);
		int count = new Integer(countAry[0].toString());
		if (count == 0)
			return false;
		else
			return true;
	}

	public void delete(TrMessageCommend tmc) {
		String sql = "delete from t_r_messagecommend where messageId = "
				+ tmc.getMessageId();
		dao.delete(sql);
	}

	public void save(TrMessageCommend tmc) {
		dao.saveEntity(tmc);

	}
}
